/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package manager;

import entity.Orders;
import iface.IManager;
import java.util.ArrayList;

/**
 *
 * @author User
 */
public class OrdersManager implements IManager<Orders> {

    private Manager manager;
    private ArrayList<Orders> ordersList;

    public OrdersManager(Manager manager) {
        ordersList = new ArrayList<Orders>();
        this.manager = manager;
    }

    @Override
    public void add(Orders obj) {
        this.ordersList.add(obj);
    }

    @Override
    public void remove(Orders obj) {
        this.ordersList.remove(obj);
        obj.setStatus(false);
        this.manager.getDisabledOrdersManager().add(obj);
    }

    @Override
    public Orders replace(int index, Orders obj) {
        return this.ordersList.set(index, obj);
    }

    @Override
    public int size() {
        return this.ordersList.size();
    }

    @Override
    public Orders get(int index) {
        return this.ordersList.get(index);
    }

    public Orders getByOrdersID(int ordersID) {
        for(Orders orders: this.ordersList) {
            if(ordersID == orders.getOrdersID()) return orders;
        }
        return null;
    }
    
    public ArrayList<Orders> getByEmployeeIDUnpaid(int employeeID) {
        ArrayList<Orders> alOrders = new ArrayList<Orders>();
        for(Orders orders: this.ordersList) {
            if(orders.getEmployeeID() == employeeID && orders.isReturned() == false)
                alOrders.add(orders);
        }
        return alOrders;
    }
    
    public ArrayList<Orders> getByEmployeeID(int employeeID) {
        ArrayList<Orders> alOrders = new ArrayList<Orders>();
        for(Orders orders: this.ordersList) {
            if(orders.getEmployeeID() == employeeID)
                alOrders.add(orders);
        }
        return alOrders;
    }
}